package Code;

import jdk.jfr.Registered;

import java.util.Random;
import java.util.Scanner;

//双色球
public class Test9 {
    public static void main(String[] args) {
        int[] winningNumber = Lottery();  //中奖号码
        for (int i = 0; i < winningNumber.length; i++) {
            System.out.print(winningNumber[i] + " ");
        }
        int[] printNumber = Stake(); //输入号码
        int red = Estimate(winningNumber, printNumber);
        boolean blue = winningNumber[winningNumber.length-1] == printNumber[printNumber.length
                -1];

        if (red == 6 && blue) {
            System.out.println("10000000");
        } else if (red == 6 && !blue) {
            System.out.println("5000000");
        } else if (red == 5 && blue) {
            System.out.println("3000");
        } else if (red == 5 && !blue || red == 4 && blue) {
            System.out.println(200);
        }else if (red == 4 && !blue || red == 3 && blue) {
            System.out.println(10);
        }else if (red == 2 && blue || red == 1 && blue|| red == 0 && blue) {
            System.out.println(5);
        }else {
            System.out.println("恨遗憾，未中奖！");
        }


    }

    //生成中将号码
    public static int[] Lottery() {
        int[] winningNumber = new int[7];

        Random random = new Random();
        for (int i = 0; i < winningNumber.length - 1; i++) {
            winningNumber[i] = random.nextInt(32) + 1;
        }

        winningNumber[winningNumber.length-1] = random.nextInt(16) + 1;
        return winningNumber;
    }

    //用户输入号码
    public static int[] Stake() {
        int[] printNumber = new int[7];
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入红球号码（1-33）：");
        for (int i = 0; i < printNumber.length - 1; i++) {
            printNumber[i] = scanner.nextInt();
        }
        System.out.println("请输入蓝球号码（1-16）：");
        printNumber[printNumber.length-1] = scanner.nextInt();
        return printNumber;
    }

    //判断中奖
    public static int Estimate(int[] arr1, int[] arr2) {
        int red = 0;

        for (int i = 0; i < arr1.length - 1; i++) {
            for (int j = 0; j < arr2.length - 1; j++) {
                if (arr1[i] == arr2[j]) {
                    red++;
                    break;
                }
            }
        }

        return red;
    }

}
